<?php
/**
 * <https://y.st./>
 * Copyright © 2017 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'title' => 'Hair care and a potential unibrow',
	'body' => <<<END
<section id="general">
	<h2>General news</h2>
	<p>
		I have strange hair growing just above my nose now.
		I swear it wasn&apos;t there before.
		Am I starting to develop a unibrow?
		That&apos;ll be so weird if it&apos;s what&apos;s going on.
	</p>
	<p>
		I looked into hair care tips not too long ago, and while I&apos;m ignoring some of them, I&apos;m following others.
		One thing I&apos;m working with is the cleaning of it.
		Apparently, you shouldn&apos;t use shampoo unless your hair&apos;s actually dirty, but you should use conditioner every time.
		It&apos;s been only a few days of following this advice, and already, my hair looks loads nicer.
	</p>
	<p>
		I agreed to meet my mother today, but like usual, she&apos;s not responding to messages.
		The problem is that she&apos;s on the nation&apos;s screwiest carrier and doesn&apos;t use email.
		My messages often don&apos;t reach her via $a[SMS], but that&apos;s the method she insists I try to reach her with.
		I asked before coming over, got no response, went to her place anyway, rang the doorbell, and again got no response.
		Whatever.
		More study time for me, though I&apos;d have even more if I wasn&apos;t wasting time trying to meet her.
		I didn&apos;t even want to go when I agreed to, but she really wanted it.
		In the evening, she wrote to me to see if I was home, even though I told her I wouldn&apos;t be.
		I told her I had the morning off and had to be at work in the evening.
		If she wants to e away in the morning when we agreed to meet up, that doesn&apos;t mean she can reschedule to meet me at night when she knows I&apos;m busy.
	</p>
	<p>
		At work, I thought about something that seems to add up with my newly-discovered hodgepodge brain.
		I forget why, but at one point as a child, my mother had my testosterone levels checked.
		They turned out to be low.
		Of course they&apos;re low though, I&apos;m half feminine and the expected level doesn&apos;t account for the fact that I&apos;m not fully masculine.
	</p>
	<p>
		My <a href="/a/canary.txt">canary</a> still sings the tune of freedom and transparency.
	</p>
</section>
<section id="university">
	<h2>University life</h2>
	<p>
		I wrote up my initial discussion post for the week:
	</p>
	<blockquote>
		<p>
			A <code>ServerSocket</code> doesn&apos;t actually manage any connections, and instead just acts as a listener.
			It waits for connection requests from clients, then spawns <code>Socket</code>s to manage the new connections.
			A <code>Socket</code> isn&apos;t always on the server though.
			Clients also use <code>Socket</code>s to communicate.
			One <code>Socket</code> is needed for each the client and server machine.
			It&apos;s worth noting that one machine could be both the client and the server.
			(This is usually accomplished by having the client connect to <code>localhost.</code> or <code>127.0.0.1</code>.)
			In this case, both endpoints still need a <code>Socket</code> instance.
		</p>
		<p>
			(When using the local domain, <code>localhost.</code>, the trailing dot is usually omitted.
			However, if your system can&apos;t handle it <strong>*with*</strong> the trailing dot, it&apos;s technically a bug in your system.
			Additionally, any domain using the <code>localhost.</code> $a[TLD] is supposed to lead back to the originating machine, though in practice, most systems don&apos;t seem to implement this.
			For example, connecting to <code>example.localhost.</code> or <code>test.example.localhost.</code> <strong>*should*</strong> connect to the local machine, but usually won&apos;t because that feature is so rarely implemented.
			Again, that&apos;s a bug in your operating system&apos;s $a[DNS] resolver, not an invalid domain name.)
		</p>
		<p>
			Using the <code>ServerSocket</code> class is basically just a waiting game.
			Usually, you&apos;d want to create an instance of it using its constructor, <code>ServerSocket.ServerSocket(port)</code>, passing in an integer representing the port you want to listen on, then start up a loop and call <code>ServerSocket.accept()</code>.
			<code>ServerSocket.accept()</code> will tie up the program (or if your program is multithreaded, just that one thread of the program), and wait for an incoming connection. When it gets one, it&apos;ll return an object of type <code>Socket</code>, which you can use to complete the connection.
			If the call to <code>ServerSocket.accept()</code> isn&apos;t within a loop, your program will accept one connection, then finish up without accepting any more.
		</p>
		<p>
			If you&apos;re running the server, <code>Socket</code> objects are retuned by <code>ServerSocket.accept()</code>.
			If you&apos;re instead running the client, <code>Socket</code> objects can be obtained through the class&apos; constructor: <code>Socket.Socket(host, port)</code>.
			The host can be any valid host name, including both domain names and $a[IP] addresses, and the port must be an unsigned, 16-bit integer.
			The <code>Socket</code> object contains two streams, one for input and one for output.
			<code>Socket.getInputStream()</code> and <code>Socket.getOutputStream()</code> can be used to retrieve those, respectively.
			The book didn&apos;t cover how to handle these stream objects directly, but they can be wrapped in objects of familiar classes, such as <code>Scanner</code> and <code>PrintWriter</code>.
			When you&apos;re done using the connection, <code>Socket.close()</code> should be called to free up memory and let the other machine know you&apos;re done.
		</p>
	</blockquote>
</section>
END
);
